#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int ans, x, y;

int main(int argc, char const *argv[])
{
	freopen("init.in", "r", stdin);

	for (int i = 1; i <= 12; i++)
	{
		ans += 300;
		scanf("%d", &x);
		ans -= x;

		if (ans < 0)
		{
			printf("%d\n", -i);
			return 0;
		}

		y += ans / 100 * 100;
		ans %= 100;
	}

	printf("%d\n", ans + y / 10 * 12);
	return 0;
}
